package Factory;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class Client {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
//        Properties properties = new Properties();
//        properties.load(new FileInputStream("./config.properties"));
//        String factoryClassName = properties.getProperty("logger.factory");
//
//        loggerFactory factory = (loggerFactory) Class.forName(factoryClassName).newInstance();
//        Logger logger = factory.createLogger();
//        logger.print();
        DatabaseLoggerFactory db = new DatabaseLoggerFactory();
        db.createLogger().print();
    }
}
interface loggerFactory{
    public Logger createLogger();
}

class DatabaseLoggerFactory implements loggerFactory{
    @Override
    public Logger createLogger() {
        return new DatabaseLogger();
    }
}

class FileLoggerFactory implements loggerFactory{
    @Override
    public Logger createLogger() {
        return new FileLogger();
    }
}


abstract class Logger{
    public abstract void print();
}

class DatabaseLogger extends Logger{
    @Override
    public void print() {
        System.out.println("数据库日志");
    }
}

class FileLogger extends Logger{
    @Override
    public void print() {
        System.out.println("文件日志");
    }
}